package Meta

import (
	"db2s/ETL"
	"db2s/global"
	"db2s/parDef"
	"db2s/ref"
)

func (ma Meta) gPartitionEr(drive string) (ter PartitionEr, err error) {
	if ter, err = NewMetaPartition(drive); err != nil {
		return
	}
	return
}
func (ma Meta) partTypeMeta() (meta any, err error) {
	var ter PartitionEr
	if meta, err = parDef.CallMethod(ma.Drive, ma.Join, func(k int, v string) (result global.Return, err error) {
		if ter, err = ma.gPartitionEr(v); err != nil {
			return
		}
		if result, err = ter.PartType(parDef.CtxBackground(parDef.GeneralReadMethodParameter(ma.Parameter1[k], nil, ETL.String))); err != nil {
			return
		}
		return
	}); err != nil {
		err = ref.ErrAddPrintf("partTypeMeta", err)
		return
	}
	return
}
func partSumAnyToInt64(s, _ any) (r any, err error) {
	return ref.StringAnyToInt64(s)
}
func (ma Meta) partSumMeta() (meta any, err error) {
	var ter PartitionEr
	if meta, err = parDef.CallMethod(ma.Drive, ma.Join, func(k int, v string) (result global.Return, err error) {
		if ter, err = ma.gPartitionEr(v); err != nil {
			return
		}
		if result, err = ter.PartSum(parDef.CtxBackground(parDef.GeneralReadMethodParameter(ma.Parameter1[k], partSumAnyToInt64, ETL.String))); err != nil {
			return
		}
		return
	}); err != nil {
		err = ref.ErrAddPrintf("partTypeMeta", err)
		return
	}
	return
}
func (ma Meta) partMeta() (meta any, err error) {
	var ter PartitionEr
	if meta, err = parDef.CallMethod(ma.Drive, ma.Join, func(k int, v string) (result global.Return, err error) {
		if ter, err = ma.gPartitionEr(v); err != nil {
			return
		}
		if result, err = ter.PartMeta(parDef.CtxBackground(parDef.GeneralReadMethodParameter(ma.Parameter1[k], partSumAnyToInt64, ETL.SMap))); err != nil {
			return
		}
		return
	}); err != nil {
		err = ref.ErrAddPrintf("partMeta", err)
		return
	}
	return
}
func (ma Meta) GetPartTypeMetaS() (result any, err error) {
	return ma.partTypeMeta()
}
func (ma Meta) GetPartSumMetaS() (result any, err error) {
	return ma.partSumMeta()
}
func (ma Meta) GetPartMetaST() (result any, err error) {
	return ma.partMeta()
}
